<template>
  <router-link :to="'/goodsDetail/' + data.goods_id+'/'+data.since_seller_id"
               class="card"
               :class="{'gridCard': !type}">
    <div class="left">
      <img class="goodsImage"
           :src="data.goods_img"
           alt=""
           v-imgField />
    </div>
    <div class="right">
      <p class="goodsName">{{ data.goods_name }}</p>
      <p class="goodsPrice">
        <em>￥</em>{{ data.goods_saleprice.toFixed(2) }}
      </p>
      <p class="goodsTag">
        <span>好评率{{data.goods_positive || 0}}%</span>
      </p>
    </div>
  </router-link>
</template>

<script>
export default {
  props: {
    data: {},
    type: true
  }
}
</script>

<style lang="scss" scoped>
@import "../../../assets/css/pub";

.card {
  padding: .25rem;
  display: flex;

  background-color: #fff;
  .left {
    width: 2.4rem;
    height: 2.4rem;
    flex: none;

    .goodsImage {
      width: 100%;
      height: 100%;
      padding: 0;
    }
  }
  .right {
    padding-left: .25rem;
    width: 100%;
    height: 2.4rem;

    // 商品名称
    .goodsName {
      height: 1rem;
      line-height: .5rem;
      font-size: $default_font_size;
      color: $default_title_color;
      vertical-align: top;
      @include textHideByLine(2);
    }
    // 商品价格
    .goodsPrice {
      margin-top: .25rem;
      height: .55rem;
      font-size: .45rem;
      color: $default_price_color;
      overflow: visible;
      em {
        font-size: $default_smallfont_size;
        font-style: normal;
      }
      .reduce {
        border: .025rem solid $default_red_color;
        color: $default_red_color;
        padding: 0 .125rem;
        border-radius: .2rem;
        font-size: $default_middlefont_size;
      }
    }
    // 商品标签
    .goodsTag {
      margin-top: .2rem;
      height: .4rem;
      font-size: $default_middlefont_size;
      color: $default_subtitle_color;
      overflow: visible;
    }
  }
}

.gridCard {
  display: inline-block;
  width: 4.5625rem;
  height: 7.15rem;
  padding: .25rem;
  box-sizing: border-box;
  flex-direction: column;
  .left {
    width: 4.0625rem;
    height: 4.0625rem;
  }
  .right {
    width: 4.0625rem;
    padding-left: 0;
    padding-top: .25rem;
  }
  &:nth-child(2n) {
    margin-left: .25rem;
  }
}
</style>
